package com.beta.mapper;

import com.baomidou.mybatisplus.mapper.AutoMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.beta.dto.admin.OrderDetailDto;
import com.beta.dto.order.BackendOrderDto;
import com.beta.dto.order.OrderStatusCountDto;
import com.beta.dto.order.OrdersDto;
import com.beta.entity.Orders;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * Orders 表数据库控制层接口
 */
public interface OrdersMapper extends AutoMapper<Orders> {

    OrdersDto selectOrderById(@Param("orderId") Integer orderId);

    List<OrdersDto> getOrders(Page<OrdersDto> page, @Param("userId") Integer userId);

    List<OrdersDto> getUnpaidOrders(Page<OrdersDto> page, @Param("userId") Integer userId);

    List<OrdersDto> getDeliveringOrders(Page<OrdersDto> page, @Param("userId") Integer userId);

    List<OrdersDto> getCompleteOrders(Page<OrdersDto> page, @Param("userId") Integer userId);

    List<OrdersDto> getCompleteSalesOrders(Page<OrdersDto> page, @Param("userId") Integer userId);

    List<OrdersDto> getDeliveringSalesOrders(Page<OrdersDto> page, @Param("userId") Integer userId);

    List<OrdersDto> getAssigningSalesOrders(Page<OrdersDto> page, @Param("userId") Integer userId);

    int selectTodayOrderCount();

    OrderStatusCountDto getOrderStatusCount(@Param("userId") Integer userId);



    /**
     * 更新订单过期状态（根据创建时间）
     * @param expiredMinCreateDate 失效订单的最早创建时间
     * @return
     */
    int updateExpiresOrderStatusByCreatedAt(@Param("expiredMinCreateDate") Date expiredMinCreateDate);

    List<Orders> selectExpiredOrdersByCreatedAt(@Param("expiredMinCreateDate") Date expiredMinCreateDate);

    List<Orders> selectPickedButNotReceiptOrders(@Param("beforePickedDate") Date beforePickedDate);

    List<BackendOrderDto> getBackendOrders(Page<BackendOrderDto>page, @Param("code")String code,
                                           @Param("name")String name,@Param("status") String status,
                                           @Param("cityCode")String cityCode,@Param("payStatus")String payStatus);

    OrderDetailDto getOrderDetail(@Param("orderId") Integer orderId);

}